//
//  TracePrototypes.cpp
//  airfight
//
//  Created by aaron more on 12-9-19.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#include <iostream>
#include "TracePrototypes.h"


TracePrototypes* TracePrototypes::s_SharedTracePrototypes = NULL;

TracePrototypes* TracePrototypes::getInstance()
{
    static bool s_bFirstUsePrototypes = true;
    if (NULL == s_SharedTracePrototypes) {
        s_SharedTracePrototypes = new TracePrototypes();
        s_bFirstUsePrototypes = false;
        s_SharedTracePrototypes->init();
    }
    return s_SharedTracePrototypes;
    
}

TracePrototypes::TracePrototypes()
{
    tracePrototype_Dict = NULL;
}

bool TracePrototypes::init()
{
    tracePrototype_Dict = CCDictionary::create();
    tracePrototype_Dict->retain();
    return true;
}

TracePrototypes::~TracePrototypes()
{
    CC_SAFE_RELEASE(tracePrototype_Dict);
}

void TracePrototypes::addTrace(Trace* p_trace)
{
    int trace_id = p_trace->getTraceID();
    tracePrototype_Dict->setObject(p_trace, trace_id);
}

Trace* TracePrototypes::getTraceByID(int p_id)
{
    CCObject* tmp = tracePrototype_Dict->objectForKey(p_id);
    
    if(tmp){
        return (Trace*)tmp;
    }else{
        return NULL;
    }
}

